package com.example.springboot.controller;

import com.example.springboot.common.Result;
import com.example.springboot.entity.CustomRequest;
import com.example.springboot.entity.TeamMember;
import com.example.springboot.service.CustomService;
import com.example.springboot.service.TeamMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/customize")
public class CustomController {

    @Autowired
    private CustomService customService;

    @Autowired
    private TeamMemberService teamMemberService;

    /**
     * 获取定制选项
     */
    @GetMapping("/options")
    public Result<Map<String, Object>> getCustomizeOptions() {
        Map<String, Object> options = customService.getCustomizeOptions();
        return Result.ok(options);
    }

    /**
     * 获取定制团队成员
     */
    @GetMapping("/team")
    public Result<List<TeamMember>> getCustomizeTeam() {
        List<TeamMember> teamMembers = teamMemberService.getActiveMembers();
        return Result.ok(teamMembers);
    }

    /**
     * 提交定制需求
     */
    @PostMapping("/submit")
    public Result<Boolean> submitCustomRequest(@RequestBody CustomRequest request) {
        boolean success = customService.submitCustomRequest(request);
        if (success) {
            return Result.ok("需求提交成功！我们的顾问将在30分钟内与您联系");
        } else {
            return Result.error("提交失败，请稍后重试");
        }
    }
}